﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Samurai.Infrastructure;
using System.Windows.Input;

namespace Samurai.Client.DataContexts
{
    public class RefreshDirectoriesCommand : ICommand
    {
        private ObservableCollection<CandidateMovie> _directories;

        public RefreshDirectoriesCommand(ObservableCollection<CandidateMovie> directories)
        {            
            this._directories = directories;
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            CandidateMovie[] newMovies = DAL.Manager.Instance.GetNewCandidates(_directories);

            foreach (var movie in newMovies)
            {
                _directories.Add(movie);
            }
        }
    }
}
